home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / serien / purity / nr.42 / includes3v1 / includes3v1.lha / Intuition / sgHooks.i < prev   
Text File  |  1994-12-04  |  8KB  |  182 lines

  1. { sgHooks.i }
  2.  
  3. {$I   "Include:Exec/Types.i"}
  4.  
  5. Type
  6.    StringExtend = Record
  7.     { display specifications   }
  8.     Font        : TextFontPtr;      { must be an open Font (not TextAttr)  }
  9.     Pens        : Array[0..1] of Byte;        { color of text/backgroun              }
  10.     ActivePens  : Array[0..1] of Byte;  { colors when gadget is active         }
  11.  
  12.     { edit specifications      }
  13.     InitialModes : Integer;   { initial mode flags, below            }
  14.     EditHook     : HookPtr;      { IF non-NULL, must supply WorkBuffer  }
  15.     WorkBuffer   : String;    { must be as large as StringInfo.Buffer}
  16.  
  17.     Reserved     : Array[0..3] of Integer;    { set to 0                             }
  18.    END;
  19.    StringExtendPtr = ^StringExtend;
  20.  
  21.    SGWork = Record
  22.     { set up when gadget is first activated    }
  23.     Gad       : GadgetPtr;         { the contestant itself        }   { Gadget in C-Includes }
  24.     StrInfo   : StringInfoPtr;     { easy access to sinfo         }   { StrInfo in C-Includes }
  25.     WorkBuffer : String;           { intuition's planned result   }
  26.     PrevBuffer : String;           { what was there before        }
  27.     Modes      : Integer;          { current mode                 }
  28.  
  29.     { modified for each input event    }
  30.     IEvent     : InputEventPtr;    { actual event: do not change  }
  31.     Code       : Short;            { character code, IF one byte  }
  32.     BufferPos  : Short;            { cursor position              }
  33.     NumChars   : Short;
  34.     Actions    : Integer;          { what Intuition will do       }
  35.     LongInt    : Integer;          { temp storage for longint     }
  36.  
  37.     GInfo      : GadgetInfoPtr;    { see cghooks.h                }   { GadgetInfo in C-Includes }
  38.     EditOp     : Short;            { from constants below         }
  39.    END;
  40.    SGWorkPtr = ^SGWork;
  41.  
  42. { SGWork.EditOp -
  43.  * These values indicate what basic type of operation the global
  44.  * editing hook has performed on the string before your gadget's custom
  45.  * editing hook gets called.  You do not have to be concerned with the
  46.  * value your custom hook leaves in the EditOp field, only if you
  47.  * write a global editing hook.
  48.  *
  49.  * For most of these general edit operations, you'll want to compare
  50.  * the BufferPos and NumChars of the StringInfo (before global editing)
  51.  * and SGWork (after global editing).
  52.  }
  53.  
  54. CONST
  55.  EO_NOOP       =  ($0001);
  56.         { did nothing                                                  }
  57.  EO_DELBACKWARD=  ($0002);
  58.         { deleted some chars (maybe 0).                                }
  59.  EO_DELFORWARD =  ($0003);
  60.         { deleted some characters under and in front of the cursor     }
  61.  EO_MOVECURSOR =  ($0004);
  62.         { moved the cursor                                             }
  63.  EO_ENTER      =  ($0005);
  64.         { "enter" or "return" key, terminate                           }
  65.  EO_RESET      =  ($0006);
  66.         { current Intuition-style undo                                 }
  67.  EO_REPLACECHAR=  ($0007);
  68.         { replaced one character and (maybe) advanced cursor           }
  69.  EO_INSERTCHAR =  ($0008);
  70.         { inserted one char into string or added one at end            }
  71.  EO_BADFORMAT  =  ($0009);
  72.         { didn't like the text data, e.g., Bad LONGINT                 }
  73.  EO_BIGCHANGE  =  ($000A);        { unused by Intuition  }
  74.         { complete or major change to the text, e.g. new string        }
  75.  EO_UNDO       =  ($000B);        { unused by Intuition  }
  76.         { some other style of undo                                     }
  77.  EO_CLEAR      =  ($000C);
  78.         { clear the string                                             }
  79.  EO_SPECIAL    =  ($000D);        { unused by Intuition  }
  80.         { some operation that doesn't fit into the categories here     }
  81.  
  82.  
  83. { Mode Flags definitions (ONLY first group allowed as InitialModes)    }
  84.  SGM_REPLACE   =  (1);       { replace mode                 }
  85. { please initialize StringInfo with in-range value of BufferPos
  86.  * if you are using SGM_REPLACE mode.
  87.  }
  88.  
  89.  SGM_FIXEDFIELD = (2);       { fixed length buffer          }
  90.                                         { always set SGM_REPLACE, too  }
  91.  SGM_NOFILTER   = (4);       { don't filter control chars   }
  92.  
  93. { SGM_EXITHELP is new for V37, and ignored by V36: }
  94.  SGM_EXITHELP   = (128);       { exit with code = $5F IF HELP hit }
  95.  
  96.  
  97. { These Mode Flags are for internal use only                           }
  98.  SGM_NOCHANGE   = (8);       { no edit changes yet          }
  99.  SGM_NOWORKB    = (16);       { Buffer == PrevBuffer         }
  100.  SGM_CONTROL    = (32);       { control char escape mode     }
  101.  SGM_LONGINT    = (64);       { an intuition longint gadget  }
  102.  
  103. { String Gadget Action Flags (put in SGWork.Actions by EditHook)       }
  104.  SGA_USE        = ($1);  { use contents of SGWork               }
  105.  SGA_END        = ($2);  { terminate gadget, code in Code field }
  106.  SGA_BEEP       = ($4);  { flash the screen for the user        }
  107.  SGA_REUSE      = ($8);  { reuse input event                    }
  108.  SGA_REDISPLAY  = ($10); { gadget visuals changed               }
  109.  
  110. { New for V37: }
  111.  SGA_NEXTACTIVE = ($20); { Make next possible gadget active.    }
  112.  SGA_PREVACTIVE = ($40); { Make previous possible gadget active.}
  113.  
  114. { function id for only existing custom string gadget edit hook }
  115.  
  116.  SGH_KEY        = (1);    { process editing keystroke            }
  117.  SGH_CLICK      = (2);    { process mouse click cursor position  }
  118.  
  119. { Here's a brief summary of how the custom string gadget edit hook works:
  120.  *      You provide a hook in StringInfo.Extension.EditHook.
  121.  *      The hook is called in the standard way with the 'object'
  122.  *      a pointer to SGWork, and the 'message' a pointer to a command
  123.  *      block, starting either with (longword) SGH_KEY, SGH_CLICK,
  124.  *      or something new.
  125.  *
  126.  *      You return 0 if you don't understand the command (SGH_KEY is
  127.  *      required and assumed).  Return non-zero if you implement the
  128.  *      command.
  129.  *
  130.  *   SGH_KEY:
  131.  *      There are no parameters following the command longword.
  132.  *
  133.  *      Intuition will put its idea of proper values in the SGWork
  134.  *      before calling you, and if you leave SGA_USE set in the
  135.  *      SGWork.Actions field, Intuition will use the values
  136.  *      found in SGWork fields WorkBuffer, NumChars, BufferPos,
  137.  *      and LongInt, copying the WorkBuffer back to the StringInfo
  138.  *      Buffer.
  139.  *
  140.  *      NOTE WELL: You may NOT change other SGWork fields.
  141.  *
  142.  *      If you clear SGA_USE, the string gadget will be unchanged.
  143.  *
  144.  *      If you set SGA_END, Intuition will terminate the activation
  145.  *      of the string gadget.  If you also set SGA_REUSE, Intuition
  146.  *      will reuse the input event after it deactivates your gadget.
  147.  *
  148.  *      In this case, Intuition will put the value found in SGWork.Code
  149.  *      into the IntuiMessage.Code field of the IDCMP_GADGETUP message it
  150.  *      sends to the application.
  151.  *
  152.  *      If you set SGA_BEEP, Intuition will call DisplayBeep(); use
  153.  *      this if the user has typed in error, or buffer is full.
  154.  *
  155.  *      Set SGA_REDISPLAY if the changes to the gadget warrant a
  156.  *      gadget redisplay.  Note: cursor movement requires a redisplay.
  157.  *
  158.  *      Starting in V37, you may set SGA_PREVACTIVE or SGA_NEXTACTIVE
  159.  *      when you set SGA_END.  This tells Intuition that you want
  160.  *      the next or previous gadget with GFLG_TABCYCLE to be activated.
  161.  *
  162.  *   SGH_CLICK:
  163.  *      This hook command is called when Intuition wants to position
  164.  *      the cursor in response to a mouse click in the string gadget.
  165.  *
  166.  *      Again, here are no parameters following the command longword.
  167.  *
  168.  *      This time, Intuition has already calculated the mouse position
  169.  *      character cell and put it in SGWork.BufferPos.  The previous
  170.  *      BufferPos value remains in the SGWork.StringInfo.BufferPos.
  171.  *
  172.  *      Intuition will again use the SGWork fields listed above for
  173.  *      SGH_KEY.  One restriction is that you are NOT allowed to set
  174.  *      SGA_END or SGA_REUSE for this command.  Intuition will not
  175.  *      stand for a gadget which goes inactive when you click in it.
  176.  *
  177.  *      You should always leave the SGA_REDISPLAY flag set, since Intuition
  178.  *      uses this processing when activating a string gadget.
  179.  }
  180.  
  181.  
  182.